#include<iostream>
#include<vector>
using namespace std;

bool Find(int target, vector<vector<int> > array) {
	if (array.size() == 0 || array[0].size() == 0)
		return false;
	int i = array[0].size();
	int j = 0, k = array.size();
	while (i >= 0 && j<k)
	{
		
		if (array[j][i - 1] == target)
			return true;
		else if (array[j][i - 1]>target)
			i--;
		else
			j++;
	}
	return false;
}

int main()
{
	vector<vector<int> > a = { { 1, 2, 8, 9 }, { 2, 4, 9, 12 }, { 4, 7, 10, 13 }, { 6, 8, 11, 15 } };
	Find(0, a);
}